package com.oepm.biz.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.oepm.biz.ScoreBiz;
import com.oepm.dao.entity.QueryInfo;
import com.oepm.dao.entity.ScorePo;
import com.oepm.dao.entity.vo.UploadScoreVo;
import com.oepm.dao.mapper.ScoreMapper;
import com.oepm.vo.DataVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class ScoreBizImpl implements ScoreBiz {
    @Resource
    ScoreMapper scoreMapper;
    @Override
    public DataVo selectAll(QueryInfo queryInfo) {
        PageHelper.startPage(queryInfo.getPagenum(),queryInfo.getPagesize());
        List<ScorePo> scorePos = scoreMapper.selectAll();
        PageInfo<ScorePo> pi = new PageInfo<>(scorePos);
        return new DataVo(pi.getTotal(),pi.getList());
    }

    @Override
    public List<ScorePo> selectByName(String pname) {
        return scoreMapper.selectByName(pname);
    }

    @Override
    public UploadScoreVo selectByPid(String pid) {
        return scoreMapper.selectByPid(pid);
    }

    @Override
    public DataVo selectByAcademy(QueryInfo queryInfo, String academy , String pname) {
        PageHelper.startPage(queryInfo.getPagenum(),queryInfo.getPagesize());
        List<ScorePo> scorePos = scoreMapper.selectByAcademy(academy,pname);
        PageInfo<ScorePo> pi = new PageInfo<>(scorePos);
        return new DataVo(pi.getTotal(),pi.getList());
    }

    @Override
    public int updateScore(UploadScoreVo uploadScore) {
        return scoreMapper.updateScore(uploadScore);
    }

    @Override
    public DataVo selectByAcademys(QueryInfo queryInfo, String pname) {
        PageHelper.startPage(queryInfo.getPagenum(),queryInfo.getPagesize());
        List<ScorePo> scorePos = scoreMapper.selectByAcademys(pname);
        PageInfo<ScorePo> pi = new PageInfo<>(scorePos);
        return new DataVo(pi.getTotal(),pi.getList());
    }
}
